<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>阻止起泡</title>
    <style type="text/css">
        #form{
            height: 100px;
            width: 200px;
            border:solid 1px #0000ff;
        }
    </style>
    <script type="text/javascript">
        window.onload=function () {
            window.onclick = function (event) {
                event.stopPropagation();
                alert("window");
            }
            document.onclick = function (event) {
                event.stopPropagation();
                alert("document");
            }
            document.getElementById("form").onclick = function (event) {
                event.stopPropagation();
                alert("form");
            }
            document.getElementById("button").onclick = function (event) {
                alert("button");
            }
        }
    </script>
</head>
<body>
<form id="form">
    <input type="button" value="button" id="button">
</form>
</body>
</html>